package com.ftg.supermarket.comm;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 业务逻辑层返回信息封装
 *
 * @author 布衣
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ToPage<T> {

    private Integer code;

    private String msg;

    private T data;


    public static ToPage<Object> success() {
        return new ToPage<Object>(200, "success", null);
    }

    public static ToPage<Object> success(String msg) {
        return new ToPage<Object>(200, msg, null);
    }

    public static <T> ToPage<T> success(String msg, T data) {
        return new ToPage<T>(200, msg, data);
    }

    public static ToPage<Object> error() {
        return new ToPage<Object>(500, "error", null);
    }

    public static ToPage<String> error(String msg) {
        return new ToPage<String>(500, msg, null);
    }


}
